home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
comm
/
irc
/
HDSearch.lha
/
HDSearch
/
HDSearch.amirx
next >
Wrap
Text File
|
1999-01-10
|
12KB
|
289 lines
/*$VER: HDSearch.amirx 3.0 (09.01.99) AmIRC/HardDrive File Finder & Sender */
/* */
/* So Realy what is HDSearch. HDSeach lets you find files you know that */
/* are on your Harddrives somewheres, but you don't know where. HDSearch */
/* uses SimpleFind v2.5 by Sebastian Bauer, to search the device given, */
/* and outputs to AmIRC screen, and allows you to send found files to a */
/* selected user. Thanks to Geronimo for all the help on this project. */
/* Thanks to Sebastian Bauer for making a great program. */
/* Made for ^Snoopy^ */
/* */
/* */
/* What's it DO: Searches your HardDrives for files */
/* Allows you to send selected file(s) to a user */
/* */
/* Requirments: installed in where every you wish: */
/* «Aminet» simplefind.lha util/dir 216K 9 V2.4 of the FileFinder */
/* installed in LIBS: */
/* «Aminet» RexxTricks_386.lha util/rexx 302K ARexx function library, V38.6 */
/* «Aminet» rexxdossupport.lha util/rexx 31K V3.5 ARexx function lib */
/* «Aminet» KuangEleven25.lha comm/tcp 396K Kuang Eleven 3 */
/* Only need rexxkuang11.library from KuangEleven if you don't use. */
/* */
/* Install: put this script in Amirc/rexx/ */
/* */
/* Config: Add the following alais to amirc list */
/* */
/* FFind = /rx HDSearch FFind %p */
/* FSend = /rx HDSearch FSend %p */
/* FShow = /rx HDSearch FShow %p */
/* FINDEX = /rx HDSearch FINDEX blah */
/* UShow = /rx HDSearch UShow %p */
/* */
/* If you uses KuangEleven 3.0 Gamma(25) put HDSearch.reg in */
/* AmIRC/events/ and this will enable all the above alaises without */
/* you having to add them to AmIRC. */
/* */
/* Fill in Simplefind path below */
/* */
/* Usage: */
/* */
/* /FFind <devicename> <flags> */
/* */
/* - wildcards: "*" stands for none, one or more character(s). */
/* ---------- (identical with #? in AMIGA-DOS) */
/* "?" stands for just one character. */
/* You can use multiple *s and ?s together!! */
/* */
/* Flags: HDS flags are the simplefind Shell Arguments */
/* Read Simplefind Guide on Shell usage. */
/* */
/* /FFind DH0: PAT=Simple */
/* */
/* «HDSearch» 1. SimpleFind.info System:OPUS 1Kb 21-Jan-98 */
/* «HDSearch» 2. SimpleFindPrefs.info System:OPUS/SimpleFind 1Kb 07-Feb-98*/
/* «HDSearch» 3. SimpleFind.info System:OPUS/SimpleFind 1Kb 30-Aug-98 */
/* «HDSearch» 4. SimpleFindPrefs System:OPUS/SimpleFind 69Kb 28-Apr-98 */
/* ETC...... */
/* */
/* /FSend <%U|nick> 2,3,4 -- will send 2,3,4 to nick */
/* */
/* /FShow 2,5,7 --- will show 2,5,7 to current channel */
/* */
/* /UShow <%U|nick> 2,3,4 ---- will show 2,3,4 to User as a private msg */
/* */
/* /Findex --- will show you current indexes you have made */
/* Tips: */
/* */
/* o You can't send files with spaces in the name. */
/* o Use Simplefinds GUI to create indexes of the DIR you wish to uses. */
/* */
/* */
/* Another Great Program by Amiga Coding Syndicate */
/* (ACS) www.surf.to/Amigacs */
/* */
/* IRC:Bossman^ Email:bosman@erols.com http://www.erols.com/bosman */
/* */
/* IRC:GeRonImo Email:geronimo@tpgnet.net http://www.tpgnet.net/a/geronimo/ */
/*--------------------------------------------------------------------------*/
simplefind = 'Sys:OPUS/simplefind/simplefind'
/*--------------------------------------------------------------------------*/
libs = "rexxsupport.library rexxdossupport.library rexxtricks.library rexxkuang11.library"
DO UNTIL libs='';PARSE VAR libs lib libs;IF EXISTS('libs:'lib)|EXISTS('Libs/'lib)|EXISTS(lib) THEN DO
IF ~show('L',lib) THEN call addlib(lib,0,-30,0);END;ELSE DO;LECHO('Cannot load 'lib);EXIT;END;END
OPTIONS RESULTS
filein = 'Ram:T/HDsearchfoundfiles.txt'
fileout= 'Ram:T/HDsearchfoundfiles2.txt'
PARSE ARG type cmds
IF cmds="" THEN DO
SELECT
WHEN UPPER(type)="FFIND" THEN CECHO('Usage: /FFind <dev:> <filename> <flag>')
WHEN Upper(type)="FSEND" THEN CECHO('Usage: /FSend <nick|%U> 1 or 2,3')
WHEN Upper(type)="FSHOW" THEN CECHO('Usage: /FShow 1 or 2,3')
WHEN Upper(type)="USHOW" THEN CECHO('Usage: /UShow <nick|%U> 1 or 2,3')
WHEN Upper(type)="FINDEX" THEN CECHO('Usage: /FINDEX ')
OTHERWISE CECHO('Not a valid 'bold('HDSearch')' command')
END
EXIT
END
SELECT
WHEN UPPER(type) = 'FINDEX' THEN findx()
WHEN UPPER(type) = 'FFIND' THEN find()
WHEN UPPER(type) = 'FSEND' THEN send()
WHEN UPPER(type) = 'USHOW' THEN ushow()
WHEN UPPER(type) = 'FSHOW' THEN fshow()
OTHERWISE CECHO('Not a valid 'bold('HDSearch')' command')
END
EXIT
findx:
Address command simplefind 'AI >T:simpleindex.txt'
READFILE('T:simpleindex.txt','SI')
CECHO('Available Simplefind/HDSearch indexes')
DO x = 1 to si.0
CECHO(si.x)
END
EXIT
FIND:
PARSE VAR cmds srchpath flags
srchpath2 = PATHPART(srchpath)
/* need to find search pattern in Com and Pat */
If POS('PAT=',UPPER(flags))> 0 then do
parse var flags blah'='filename .
CECHO('Searching for 'bold(filename)' in dir/path 'BOLD(srchpath))
END
If POS('COM=',UPPER(flags))> 0 & POS('PAT=',UPPER(flags)) = 0 then do
parse var flags blah'='filename .
CECHO('Searching Comments for 'bold(filename)' in dir/path 'BOLD(srchpath))
END
If POS('BETWEEN=',UPPER(flags))>0 & POS('COM=',UPPER(flags))=0 & POS('PAT=',UPPER(flags))=0 then do
parse var flags blah'='filename .
CECHO('Searching for file Between 'bold(filename)' in dir/path 'BOLD(srchpath))
filename = 'Files Bewteen 'filename
END
if filename="FILENAME" then filename='Unkown'
TIME(E)
IF ~EXISTS(srchpath2) THEN DO;CECHO(BOLD(srchpath) 'is not a valid device/path');EXIT;END
CECHO('Please be patient this may take some time')
Address command simplefind srchpath2 flags 'LFORMAT "%p%n %l %d" >'filein
CHECKSIZE()
OPEN(file2,fileout,'W')
OPEN(file,filein,'R')
x=0
DO UNTIL EOF(file)
line = READLN(file)
x=x+1
IF line = '' THEN leave
numwords = WORDS(line)
date = WORD(line,numwords)
size = WORD(line,numwords-1)
line = DELWORD(line,numwords-1,2)
parse var line drive":"fileline
IF WORDS(drive) > 1 THEN do
HDdatafile = 'T:HDS-drivelist.txt'
Address Command 'C:info > 'HDdatafile
OPEN(HDfile,HDdatafile,'R')
DO UNTIL EOF(HDfile)
line = READLN(HDfile)
IF POS(UPPER(drive),UPPER(line)) > 0 THEN DO
drive = COMPRESS(WORD(line,1),':')
LEAVE
END
END
END
CLOSE(HDfile)
DELETE(HDdatafile)
fp=FILEPART(drive':'fileline)
ndir=PATHPART(drive':'fileline)
size = realsize(size)
newline = x'. 'fp' -- 'ndir' 'size' 'date
WRITELN(file2,newline)
cecho(bold(x)'. 'fp' 'ndir' 'size' 'date)
END
CLOSE(file)
CLOSE(file2)
DELETE(filein)
etime = TIME(E)
parse var etime secs'.'ticks
CECHO('HDSearch for 'bold(filename)' completed in 'secs' sec(s)')
EXIT
SEND:
CHECKDATAFILE()
IF DATATYPE(WORD(cmds,1))='NUM' then do;CECHO('You need to enter a Nick, then file numbers')
EXIT;END
IF UPPER(WORD(cmds,1)) = '%U' THEN DO
"GETSELECTEDUSER";foruser=result
END
ELSE foruser = WORD(cmds,1)
cmds = SUBWORD(cmds,2)
DO UNTIL cmds = ' '
PARSE VAR cmds file','cmds
filenum = COMPRESS(file'.')
fileline = SEARCHFOR(fileout,filenum)
numwords = WORDS(fileline)
fileline = delword(fileline,numwords-1,2)
fileline = delword(fileline,1,1)
parse var fileline filenme'--'dirpath
if words(filenme) > 1 then do
Cecho('HDSearch can''t send a file with spaces')
Cecho('I''m working on this problem.. seems it may be AmIRC')
Exit
end
fileloc = makepath(strip(dirpath),strip(filenme))
IF exists(fileloc) then do
CECHO('Sending 'bold(filepart(fileloc))' to 'foruser)
'SAY /DCC Send 'foruser fileloc
END
Else CECHO(bold(fileloc) 'does not exists')
END
EXIT
FSHOW:
DO UNTIL cmds = ' '
PARSE VAR cmds file','cmds
filenum = COMPRESS(file'.')
fileline = SEARCHFOR(fileout,filenum)
'say 'bold('«HDSearch»') fileline
END
EXIT
USHOW:
Parse var cmds nick cmds
IF UPPER(nick) = '%U' THEN DO
"GETSELECTEDUSER";nick=result
END
DO UNTIL cmds = ' '
PARSE VAR cmds file','cmds
filenum = COMPRESS(file'.')
fileline = SEARCHFOR(fileout,filenum)
'say /msg' nick fileline
END
EXIT
realsize:
bsize = arg(1)
select
when length(bsize)~>3 then do
size='1Kb'
return size
end
when length(bsize)~>6 then do
size=trunc(bsize/1024)'Kb'
return size
end
otherwise do
size=trunc(bsize/1024)'Kb'
return size
end
end
CHECKSIZE:
fl = STATEF(Filein)
filesize = WORD(fl,2)
IF filesize = 0 then do
CECHO('No files found matching 'bold(filename))
DELETE(Filein)
EXIT
END
Return 0
CHECKDATAFILE:IF ~EXISTS(fileout) THEN DO;CECHO('No Data file found');EXIT;END;RETURN 0
LECHO:;"ECHO P="d2c(27)"b«"Error"» C=6" arg(1);RETURN 0
CECHO:;"ECHO P="d2c(27)"b«HDSearch» C=0" arg(1);RETURN 0